package com.xiaoqi.springboot.myconfig;

import com.xiaoqi.springboot.interceptor.MyHandlerInterceotor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author Rookie Coder
 * @Description
 * @Date
 **/
@Configuration
public class MyConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 指定拦截的路径
        String[] addPathpatterns={"/user/centent"};

        // 指定放行的路径
        String[] excludePathPatterns={"/user/login","/user/anyPage","/user/error"};

        // 注册拦截器，添加拦截的指定路径和放行路径
        registry.addInterceptor(new MyHandlerInterceotor()).addPathPatterns(addPathpatterns).excludePathPatterns(excludePathPatterns);

    }
}
